/*
https://leetcode.cn/problems/coin-change/?envType=problem-list-v2&envId=dynamic-programming
322. 零钱兑换
*/
class Solution {
public:
    int coinChange(vector<int>& coins, int amount) {
        int leng=coins.size();
        vector<int>dp(amount+1,amount+1);
        dp[0]=0;
        for(int i=1;i<=amount;++i){
            for(int j=0;j<leng;++j){
                if(coins[j]<=i) dp[i]=min(dp[i],dp[i-coins[j]]+1);
            }
            cout<<dp[amount]<<endl;
        }
        return dp[amount]>amount?-1:dp[amount];
    }
};